export function getTimeAgo(timestamp) {
    const now = Date.now();
    const diff = now - timestamp; // 计算时间差（毫秒）

    if (diff < 0) return null; // 处理未来时间

    // 时间单位转换
    const seconds = Math.floor(diff / 1000);
    if (seconds < 60) return "一分钟以内";

    const minutes = Math.floor(seconds / 60);
    if (minutes < 60) return `${minutes}分钟`;

    const hours = Math.floor(minutes / 60);
    if (hours < 24) return `${hours}小时`;

    const days = Math.floor(hours / 24);
    if (days < 30) return `${days}天`;

    const months = Math.floor(days / 30);
    return months < 3 ? `${months}个月` : null;
}

export const gotoHone = ()=>{
	uni.showModal({
		title:"提示",
		content:"即将跳转到首页",
		success(res) {
			if(res.confirm){
				uni.reLaunch({
					url:'/pages/index/index'
				})
			}
		}
	})
}

import {API_HOST,API_PROXY} from "../config.js"

/**
 * 组装接口url
 */
export const packApiUrl = (url = '') => {
  if (url.slice(0, 4) === 'http') return url
  else return `${API_HOST}${API_PROXY}${url}`
}
